﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _63多态练习
{
    class Program
    {
        static void Main(string[] args)
        {
            RealYi yi = new RealYi();
            RealEr er = new RealEr();
            RealSan san = new RealSan();
            RealYi[] docks = { yi, er, san };
            for(int i = 0; i < docks.Length; i++)
            {
                docks[i].Bark();
            }
            Console.ReadKey();

        }

        public class RealYi
        {
            public virtual void Bark()
            {
                Console.WriteLine("真的鸭子嘎嘎叫");
            }
        }

        public class RealEr:RealYi
        {
            public override void Bark()
            {
                Console.WriteLine("木头鸭子吱吱叫");
            }
        }

        public class RealSan:RealYi
        {
            public override void Bark()
            {
                Console.WriteLine("橡皮鸭子唧唧叫");
            }
        }
    }
}
